home *** CD-ROM | disk | FTP | other *** search
/ MacGames Sampler / PHT MacGames Bundle.iso / MacSource Folder / Samples from the CD / C and C++ / POSIX / ThinkCPosix / Open.c < prev    next >
Text File  |  1992-09-22  |  459b  |  21 lines

  1. /* $Id: $ */
  2.  
  3. /*
  4.  * This replacement for open() deals with 2 problems:
  5.  * (1) open() is often given with 3 arguments;
  6.  * (2) if an attempt is made to open a file :dirname:filename
  7.  *     and there is no directory dirnam,
  8.  *     open() returns ENOTDIR, where Unix would return ENOENT.
  9.  */
  10.  
  11. #include "ThinkCPosix.h"
  12.  
  13. int Open(char *filename, int mode, ...)
  14. {
  15.     int fd;
  16.     fd = open(filename, mode);
  17.     if (fd < 0 && errno == ENOTDIR)
  18.         errno = ENOENT;
  19.     return fd;
  20. }
  21.